import React from 'react'
import { Button, Upload, message as antdMessage } from 'antd'
import { UploadChangeParam, UploadFile } from 'antd/es/upload';
const Index: React.FC = () => {
  const beforeUpload = (file: File) => {
    if(!file.type.includes('image')) {
      antdMessage.error("只可以上传图片");
      return Upload.LIST_IGNORE
    }
  }
  const onchange = (info: UploadChangeParam<UploadFile<any>>) => {
    console.log(info)
  }
  return (
    <div>
      <Upload beforeUpload={beforeUpload} action="/api/upload" method="POST" onChange={onchange
      }>
        <Button>点我上传</Button>
      </Upload> 
    </div>
  )
}

export default Index;